/**
 *
 * by littlefean
 */
window.onload = function () {
    let N = 0;

    let goEle = document.querySelector(`.go`);
    let inputArea = document.querySelector(`.inputArea`);
    let choice = document.querySelector(`.choice`);

    for (let btn of choice.children) {
        btn.addEventListener("click", () => {
            let text = btn.innerHTML;
            let n = +text;
            N = n;
            inputArea.innerHTML = "";
            for (let y = 0; y < n; y++) {
                let line = div("", "line");
                for (let x = 0; x < n; x++) {
                    let inputBox = document.createElement("input");
                    inputBox.classList.add("inputBox");
                    inputBox.placeholder = "0";
                    line.appendChild(inputBox);
                }
                inputArea.appendChild(line);
            }
        })
    }

    let output = document.querySelector(`.output`);


    goEle.addEventListener("click", () => {
        output.innerHTML = "";
        if (N === 0) {
            output.innerHTML = "您还没有选择行列式的阶数，请先选择阶数";
        } else {
            let d = [];
            for (let lineEle of inputArea.children) {
                let line = [];
                for (let inputBox of lineEle.children) {
                    line.push(+inputBox.value);
                }
                d.push(line);
            }
            let res = dec(d);
            output.innerHTML = (`最终结果是${res}`);
        }
    })


}
